<template>
  <page-frame>
    <div class="healthAssessment">
      <div class="toptitle">
        <div class="left">健康评估  - {{$data.currentMemberName}}  - 历史评估</div>
        <div class="right">
          <div class="btns">
            <el-button @click="backStaff" class="lightGreenBtn">返回</el-button>
          </div>
        </div>
      </div>
      <div style="border-bottom: 1px solid #ccc;height: 1px; margin:8px 0px 20px 0px;"></div>
      <div class="file-main">
        <div class="tabs">
          <el-table
            :data="tableData"
            border
            highlight-current-row
            @cell-dblclick="schedule=true"
            style="width: 100%">
            <el-table-column
              prop="assessNo"
              label="评估编号"
            >
            </el-table-column>
            <el-table-column
              prop="sheetName"
              label="评估量表名称"
            >
            </el-table-column>
            <el-table-column
              prop="memberName"
              label="评估对象"
            >
            </el-table-column>
            <el-table-column
              prop="emName"
              label="评估员"
            >
            </el-table-column>
            <el-table-column
              prop="timeStart"
              label="开始时间"
            >
            </el-table-column>
            <el-table-column
              prop="timeEnd"
              label="结束时间"
            >
            </el-table-column>
            <el-table-column
              prop="statusName"
              label="状态"
            >
            </el-table-column>
            <el-table-column
              prop="operating"
              label="操作"
              width=""
            >
              <template scope="scope">
                <el-button v-show="scope.row.lookStatus" type="text" size="small" @click.stop="lookSheet(scope.row,0)">详情</el-button>
              </template>
            </el-table-column>
          </el-table>

          <div class="pagination">
            <div class="block">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChangePage"
                :current-page="pageData.currentPage1"
                :page-size="10"
                layout="total, prev, pager, next"
                :total="total">
              </el-pagination>
            </div>
          </div>
        </div>
      </div>
    </div>
  </page-frame>
</template>

<script >
  import Vue from 'vue'
  import VueResource from 'vue-resource';
  Vue.use(VueResource);
  import common from '../../config/common'
  export default {
    methods: {
      init(){
        this.currentMemberId=this.$route.params.memberId; //获取url地址的id
        this.currentMemberName=this.$route.params.memberName; //获取url地址的memberName
        this.loadTableData();
      },
      loadTableData(){
        let self = this;
        var url = "/assessSet/m/v1/getAssessmentsandmeberId/" +this.currentMemberId+ "/" + 10 + "/" + self.currentPage+"?"+"accessId=0";
        Vue.http.get(url).then(
          (response) => {
        self.tableData = response.data.data.list;
        self.total = response.data.data.total;
        if (self.tableData.length!=0){
          for(let i=0;i<self.tableData.length;i++) {
            //判断当前状态
            switch (this.tableData[i].status) {
              case 2:
                self.tableData[i].statusName = "已完成";
                self.tableData[i].lookStatus = true;
                break;
              case 3:
                self.tableData[i].statusName = "已中止";
                self.tableData[i].lookStatus = true;
                break;

            }
          }
        }
      },
        (response) => {},
      );
      },

      backStaff(){
        this.$router.push({name: 'assessmentAdd'});
      },

      lookSheet(obj,status){
        this.$router.push({name:"assessmentDetails",params: {memberObj: obj,status: status}});
      },
      query(){
        this.loadTableData();
      },

      exportOrder(){
      },
      handleCurrentChange(val) {
      },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChangePage(val) {
        this.currentPage = val;
        console.log(`当前页: ${val}`);
        this.loadTableData();

      },
    },

    mounted: function () {
      this.init();
    },
    components:{
      'my-compont1':{
//        props:['msg'], /*这里是为子模板传值*/
        template:"<input type='text' value='my-compont1'/>"
      },
      'my-compont2':{
//        props:['msg'], /*这里是为子模板传值*/
        template:"<input type='text' value='my-compont2'/>"
      }
    },
    data () {
      return {
        currentMemberName:null,
        currentMemberId:null,
        leaveDate:"",
        leave:false,
        currentPage:1,
        schedule:false,
        tableData:[],
        total:1,
        pageData:[{
          currentPage1: 1,
        }],
      }
    },
  }
</script>
<style>
  .healthAssessment .input .input-item{
    margin-bottom: 20px;
    margin-top: 15px;
  }
  .healthAssessment .input .btns{
    float:none!important;
    display:inline-block;
  }
  .healthAssessment .el-input{
    width: 80%;
  }
  .healthAssessment .input input{
    display: inline-block;
  }
  .healthAssessment .scroll{
    height: calc(100vh - 122px);
    padding:0px 50px;
  }
  .healthAssessment .el-pagination{
    margin-right:0!important;
    padding-right:0!important;
  }
  .healthAssessment .el-select {
    display: block;
    position: relative;
  }
  .healthAssessment .query{
    margin-right:30px;
  }
</style>
